package com.mhxy.service.impl;

import com.mhxy.constant.PicConstants;
import com.mhxy.handler.TaskProgressHandler;
import com.mhxy.service.AbstractTask;
import com.mhxy.util.FuzzyPicUtil;
import com.mhxy.util.ThreadUtil;
import com.sun.jna.platform.win32.WinDef;

/**
 * 擂台大挑战
 */
public class LeiTaiTaskImpl extends AbstractTask {
    public LeiTaiTaskImpl(WinDef.HWND hwnd_0) {
        super(hwnd_0);
    }

    @Override
    public Boolean before() throws Exception {
        return true;
    }

    @Override
    public Boolean execute() throws Exception {
        int count = 0;
        while (true) {
            count++;
            TaskProgressHandler.updateProgress(getTaskName(), count + "次");

            if(FuzzyPicUtil.findAndClickRandom(hwnd_0, PicConstants.擂台大挑战_开始匹配, 1)) {
                ThreadUtil.sleep(30000);
            }

            findBattle(10000);

        }
//        return true;
    }

    @Override
    public Boolean after() throws Exception {
        return true;
    }

    @Override
    public String getTaskName() throws Exception {
        return "擂台大挑战";
    }
}
